package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.PageQuery;
import com.zzyl.nursing.dto.BindFamilyMemberDTO;
import com.zzyl.nursing.dto.HealthDataDayDto;
import com.zzyl.nursing.dto.HealthDataDto;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 家属-老人多对多中间Controller
 * 
 * @author alexis
 * @date 2025-10-26
 */
@Api("家属-老人多对多中间管理")
@RestController
@RequestMapping("/member/user")
public class FamilyMemberElderController extends BaseController
{
    @Autowired
    private IFamilyMemberElderService familyMemberElderService;


    /**
     * 绑定家人
     */
    @PostMapping("/add")
    public AjaxResult postFamilyMember(@RequestBody BindFamilyMemberDTO bindFamilyMemberDTO) {
        familyMemberElderService.postFamilyMember(bindFamilyMemberDTO);
        return success();
    }
    /**
     * 解绑老人
     */
    @DeleteMapping("deleteById")
    public AjaxResult deletefamilyMember(@RequestParam Long id){
        familyMemberElderService.removeById(id);
        return success();
    }

    /**
     * 查询家人列表
     * @return
     */
    @GetMapping("/my")
    public AjaxResult getFamilyMemberList() {
        List<FamilyMemberListVO> vo = familyMemberElderService.getFamilyListByUserId();
        return success(vo);
    }

    /**
     * 查看家人列表（分页查询）
     */
    @GetMapping("/list-by-page")
    public AjaxResult getFamilyMemberListByPage(PageQuery pageQuery)
    {
        startPage();
        List<FamilyMemberElderpageVo> vo = familyMemberElderService.getFamilyMemberListByPage(pageQuery);
        return success(vo);
    }

    /**
     * 健康数据
     * @param healthDataDto
     * @return
     */
    @PostMapping("/QueryDevicePropertyStatus")
    public AjaxResult healthData(@RequestBody  HealthDataDto healthDataDto){
        HealthDataVO healthDataVO = familyMemberElderService.healthData(healthDataDto);
        return success(healthDataVO);
    }

    /**
     * 查询当日数据
     * @param healthDataDayDto
     * @return
     */

    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult healthDayData(HealthDataDayDto healthDataDayDto){
        List<HealthVo> list = familyMemberElderService.healthDayData(healthDataDayDto);
        return AjaxResult.success(list);
    }
    /**
     * 查询当周数据
     * @param healthDataDayDto
     * @return
     */

    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult healthWeekData(HealthDataDayDto healthDataDayDto){
        List<HealthWeekVo> list = familyMemberElderService.healthWeekData(healthDataDayDto);
        return AjaxResult.success(list);
    }
}
